<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
  <link rel="stylesheet" href="./font_3366928_6aytrri25q9/iconfont.css">

  <link rel="stylesheet" href="./css/优惠券页面.css">
<script src="./js/jquery.min.js"></script>

 <!-- <script src="./js/优惠券页面.js"></script> -->
 <script src="./flexible.js"></script>

</head>
<body>

    <div class="box">
        <i class="iconfont icon-zuojiantou1"></i>

        <h3>优惠券 </h3>
          <i class="iconfont icon-xiazai"></i>
    
    </div>
   
    <ul class="ull">
      <!-- <li>
        <img>
        <span>肯德基</span>
      </li>
      <li>
        <img>
        <span>肯德基</span>
      </li>
      <li>
        <img>
        <span>肯德基</span>
      </li>
      <li>
        <img>
        <span>肯德基</span>
      </li> -->
    </ul>

    <div class="sh">
      <span>&ensp;&ensp;&ensp;首页 ></span>
    <span> 优惠券</span>
    </div>
    
    <div class="bot">
      <span>登入</span>
      <span>注册</span>
      <span>
        <i class="iconfont icon-fangzi"></i>
        返回顶部</span>
    </div>
  
    <span class="papa">手机app下载</span><span class="pp1">万峰智慧商城手机版 -- 掌上比价平台</span>
    <span class="pp2">m.manmanmbuy/.com</span>
  

    <script>
      var ull =document.querySelector('.ull')
          let xhr=new XMLHttpRequest()
          xhr.open('get','http://chst.vip:1234/api/getcoupon',true)
          xhr.onload=function(){
              if(xhr.status===200){
                  let res=JSON.parse(xhr.responseText)
              console.log(res.result)
              var lis=''
              let regExp = /^<[^<]+\s+src="([^''""]*)"/;

              res.result.forEach((ele,ind) => {
              // let tu = res.result[ind].couponImg.match(regExp);
              var tu = regExp.exec(ele.couponImg);

              console.log(tu)

                  lis+=`
                  <li couponid="${ele.couponId}">
                  <img src="${tu}">
                  <span>${ele.couponTitle}</span>
                </li>
                  
                  `
              })
            
                ull.innerHTML=lis

                ull.onclick=function(ev){
              let e=ev||window.event

              let target=e.target||e.srcElement
              console.log(target.nodeName);

              if(target.nodeName==='LI'){
                   localStorage.setItem('couponid',target.getAttribute('couponid'))
              }else{
                   localStorage.setItem('couponid',target.parentNode.getAttribute('couponid'))

              }
              location.href='./品牌优惠券.html'
          }
   

          
          }

          }  
          xhr.send()


          
          var ding = document.querySelector('.bot span:nth-of-type(3)')

          ding.style.color = '#c36'
          ding.onclick = function () {
            document.documentElement.scrollTop = 0
          }

          $('.icon-zuojiantou1').click(function(){
  location.href="./商品首页.html"
})


        
   
          

    </script>
</body>
</html>